﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Catchbase.TestTools.UTest
{
    [TestClass]
    public class AssertionsTest
    {
        [TestMethod]
        public void MustBeInstanceOf()
        {
            new Object().MustBeInstanceOf(typeof(Object));
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustBeInstanceOfFails()
        {
            new Object().MustBeInstanceOf(typeof(String));
        }

        [TestMethod]
        public void MustBeTrue()
        {
            true.MustBeTrue();
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustBeTrueFails()
        {
            false.MustBeTrue();
        }

        [TestMethod]
        public void MustBeFalse()
        {
            false.MustBeFalse();
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustBeFalseFails()
        {
            true.MustBeFalse();
        }

        [TestMethod]
        public void MustBeEqual()
        {
            "Oi".MustEqual("Oi");
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustBeEqualFails()
        {
            "Oi".MustEqual("");
        }

        [TestMethod]
        public void MustBeSame()
        {
            var o = new object();
            o.MustBeSame(o);
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustBeSameFails()
        {
            var o = new object();
            o.MustBeSame(new object());
        }

        [TestMethod]
        public void MustNotBeSame()
        {
            var o = new object();
            o.MustNotBeSame(new object());
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustNotBeSameFails()
        {
            var o = new object();
            o.MustNotBeSame(o);
        }
        
        [TestMethod]
        public void MustContain()
        {
            var o = new object();
            new List<object>{o}.MustContain(o);
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustContainFails()
        {
            var o = new object();
            new List<object> { o }.MustContain(new object());
        }

        [TestMethod]
        public void MustNotContain()
        {
            var o = new object();
            new List<object>{new object()}.MustNotContain(o);
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustNotContainFails()
        {
            var o = new object();
            new List<object> { o }.MustNotContain(o);
        }
        
        [TestMethod]
        public void MustContainExactly()
        {
            var o = new object();
            new List<object> { o }.MustContainExactObjects(o);
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustContainExactlyFails()
        {
            new List<object> { new object() }.MustContainExactObjects(new object());
        }

        [TestMethod]
        public void MustSize()
        {
            new List<object> {new object()}.MustSize(1);
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustSizeFails()
        {
            new List<object> { new object() }.MustSize(2);
        }

        [TestMethod]
        public void MustStartWith()
        {
            "Hello world".MustStartWith("Hello");
        }

        [TestMethod]
        [ExpectedException(typeof(AssertFailedException))]
        public void MustStartWithFails()
        {
            "Hello world".MustStartWith("o");
        }
    }
}